package net.dengzixu.java.homework.period6;

import java.util.Scanner;

/**
 * @author Deng Zixu <admin@dengzixu.com>
 */
public class Period6Homework3 {
    private static final double XIALI_BASE_PRICE = 7;
    private static final double XIALI_EXTRA_PRICE = 2.1;

    private static final double FUKANG_BASE_PRICE = 8;
    private static final double FUKANG_EXTRA_PRICE = 2.4;

    private static final double SANTANA_BASE_PRICE = 10;
    private static final double SANTANA_EXTRA_PRICE = 2;


    private static final byte VEHICLE_TYPE_XIALI = 0;
    private static final byte VEHICLE_TYPE_FUKANG = 1;
    private static final byte VEHICLE_TYPE_SANTANA = 2;


    public static void main(String[] args) {
        // 载具类型  0: 夏利; 1: 富康; 2: 桑塔纳
        int vehicleType;

        // 里程
        double mileage;

        // 基础里程
        double baseMileage;

        // 额外里程
        double extraMileage;

        // 总价
        double totalPrice = 0;

        Scanner scanner = new Scanner(System.in);

        System.out.print("请选择车辆类型[0: 夏利; 1: 富康; 2: 桑塔纳]: ");

        vehicleType = scanner.nextInt();

        System.out.print("请输入里程数(单位: 千米，可以为小数): ");

        mileage = scanner.nextDouble();

//        if (mileage <= 3) {
//            extraMileage = 0;
//        } else {
//            extraMileage = mileage - 3;
//        }

        // 三元选择符
        extraMileage = mileage <= 3 ? 0 : (mileage - 3);


        switch (vehicleType) {
            case VEHICLE_TYPE_XIALI:
                totalPrice += XIALI_BASE_PRICE;
                totalPrice += extraMileage * XIALI_EXTRA_PRICE;
                break;
            case VEHICLE_TYPE_SANTANA:
                totalPrice += SANTANA_BASE_PRICE;
                totalPrice += extraMileage * SANTANA_EXTRA_PRICE;
                break;
            case VEHICLE_TYPE_FUKANG:
                totalPrice += FUKANG_BASE_PRICE;
                totalPrice += extraMileage * FUKANG_EXTRA_PRICE;
                break;
            default:
                System.out.println("您坐错车了");
                return;
        }

        System.out.println("车费为: " + totalPrice);


    }
}
